package com.jwdf.uda.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by liuli on 2015/11/27.
 */
public class DateUtil {


    /**
     * 使用用户格式提取字符串日期
     *
     * @param strDate 日期字符串
     * @param pattern 日期格式
     * @return
     */

    public static Date parse(String strDate, String pattern) {

        if (TextUtil.isEmpty(strDate)) {
            return null;
        }
        try {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            return df.parse(strDate);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 使用用户格式格式化日期
     *
     * @param date    日期
     * @param pattern 日期格式
     * @return
     */

    public static String format(Date date, String pattern) {
        String returnValue = "";
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            returnValue = df.format(date);
        }
        return (returnValue);
    }

    public static String getConstellation(int month, int day) {
        String[] constellations = new String[]{"摩羯座", "水瓶座", "双鱼座", "白羊座", "金牛座",
                "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座"};
        int[] threshold = new int[]{20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22};
        int index = month;
        if (day < threshold[month - 1]) {
            index = index - 1;
        }
        return constellations[index];
    }

    public static String getConstellations(int number){
        String[] constellation = new String[]{ "","白羊座", "金牛座", "双子座", "巨蟹座", "狮子座",
                "处女座", "天秤座", "天蝎座", "射手座", "摩羯座","水瓶座", "双鱼座"};
        return constellation[number];
    }

    public static String format(String time) {
        String returnValue = "";

        return (returnValue);
    }


//    public static PbBean.PbSignUserConstellation getUserConstellation(String constellations){
//        String[] constellation = new String[]{ "","白羊座", "金牛座", "双子座", "巨蟹座", "狮子座",
//                "处女座", "天秤座", "天蝎座", "射手座", "摩羯座","水瓶座", "双鱼座"};
//        int
//        for(int i=0;i<constellation.length;i++){
//            if(constellation.equals(constellation[i])){
//                PbBean.PbSignUserConstellation.internalGetValueMap();
//            }
//        }
//        return "";
//    }



}
